Test Series - java script

Test Number 79/92

Q: What is the initial step to set up a CSS Lazy Loading?
A. Fetching data
B. Loading the script
C. Loading the page
D. Adding the event listener
Solution: The loading attribute allows a browser to defer loading offscreen images and iframes until users scroll near them. The CSS Lazy Loading is begun with fetching the JavaScript and the CSS files.
Q: What is the purpose of holding whatever tag you create in the attribute type?
A. To have more information
B. To identify the scripting language
C. To store data
D. To store variable name
Solution: A variable is created to hold whatever tag you create, and then branch the logic based on the value of type, which identifies it’s for JavaScript or for CSS. Hence, the attribute acts as an identifier to the tag.
Q: What does the appendChild() method perform?
A. Appends a node in the middle of the index taken as the parameter
B. Appends a node as the first child
C. Appends a node as the last child
D. Replaces and appends at the last node
Solution: The appendChild() method appends a node as the last child of a node. You can also use this method to move an element from one element to another.
Q: What is being done in the following JavaScript code?

A. JS and CSS files are deleted
B. CSS is replaced with JS
C. JS is replaced with CSS
D. JS and CSS files are loaded
Solution: In the above function, the JavaScript and the CSS files are loaded remotely. The loadURls method returns a promise which will receive the temporary folder as an argument.
Q: What should be the value of the type attribute of a variable if the type of file is CSS?
A. text/js/css
B. text/js
C. text/css
D. text
Solution: Since the type of file is CSS, the type attribute should hold the value text/css. For javascript file type attribute would hold the vale text/js.
Q: How to lazy load images?
A. Remove the rel attribute
B. Remove the src attribute
C. Make rel = src
D. Make src = rel
Solution: The way we would lazy load images would be to alter the HTML of the page to remove the contents of the src attribute of each image. We could just move the contents of the src attribute to an attribute in the image tag of our own design, maybe the rel attribute.
Q: What does the rel attribute of a variable have when the type of file is CSS?
A. css
B. stylesheet
C. text/css
D. plainsheet
Solution: A web style sheet is a form of separation of presentation and content for web design in which the markup (i.e., HTML or XHTML) of a webpage contains the page’s semantic content and structure, but does not define its visual layout (style). The rel attribute must hold the value rel = ‘stylesheet’.
Q: What is the parameter of the method getElementsbyTagName() if we need to get an image?
A. image
B. src
C. img
D. imageurl
Solution: To get the source attribute the parameter is src. The method must look like getElementsbyTageName(“img”) if we need to get an image.
Q: How do we stop blocking of loading and executing the perfLogger, a logging type data?
A. Inlining the perfLogger
B. Removing the perfLogger
C. Placing the perfLogger before the “script” tag
D. Placing the perflogger after the “script” tag
Solution: A performance logging tool that provides file logging with timestamp and memory usage statistics. On calling End() a csv file of logged items will be generated. By inlining the perfLogger, we no longer block the loading and executing of it.

You Have Score    /9